<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\ProductSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '产品管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="col-xs-12">
    <div class="box">
        <div class="box-header">
            <p>
                <?= Html::a('新增产品', ['create'], ['class' => 'btn btn-success']) ?>
            </p>
            <!-- Check all button -->
            <!-- /.btn-group -->
            <a type="button" class="btn btn-default btn-sm" href="javascript:window.location.reload()"><i
                        class="fa fa-refresh"></i></a>
            <div class="visible-lg-block pull-right">
                <?php echo $this->render('_search', [
                    'model' => $searchModel,
                ]); ?>
                <!-- /.btn-group -->
            </div>
            <!-- /.pull-right -->
        </div>

        <!-- /.box-header -->
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            'layout' => "<div class=\"box-body table-responsive\">{items}</div>\n<div class=\"box-footer clearfix\"><div class=\"row\"><div class=\"col-xs-12 col-sm-7\">{pager}</div><div class=\"col-xs-12 col-sm-5 text-right\">{summary}</div></div></div>",
            'tableOptions' => ['class' => 'table table-bordered table-hover'],
            'summary' => '第{page}页，共{pageCount}页，当前第{begin}-{end}项，共{totalCount}项',
            'filterModel' => null,
            'pager' => [
                'class' => 'yii\widgets\LinkPager',
                'options' => [
                    'class' => 'pagination pagination-sm no-margin',
                ],
            ],
            'columns' => [
                ['class' => 'yii\grid\SerialColumn'],

                'goods_sn',
                'product_name',
                'price',
                'code',
                [
                    'class' => 'yii\grid\ActionColumn',
                    'header' => '操作',
                    'template' => '{view} {update} {delete} {generate}',
                    'buttons' => [
                        'generate' => function ($url, $model, $key){
                            return Html::a('<span class="glyphicon glyphicon-share"></span>', $url, ['title' => '生成', 'class' => 'btn btn-default btn-sm']);
                        }
                    ],
                    'headerOptions' => ['style' => 'width:150px'],
                    'buttonOptions' => ['class' => 'btn btn-default btn-sm'],
                ],
            ],
        ]); ?>
        <!-- /.box-body -->
    </div>
    <!-- /.box -->
</div>
